import ACCESS_ENUM from "@/access/accessEnum";

const checkAccess = (loginUser: any, needAccess: string) => {
  /**
   * 不需要登录直接放行
   */
  if (needAccess === undefined) {
    return true;
  } else {
    if (loginUser.userRole === undefined) {
      return false;
    }
    if (needAccess === ACCESS_ENUM.LOGIN) {
      return true;
    }
    return loginUser.userRole === needAccess;
  }
};

export default checkAccess;
